package cn.bocweb.spinning.view.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebView;

import butterknife.Bind;
import butterknife.BindColor;
import butterknife.ButterKnife;
import cn.bocweb.spinning.R;
import cn.bocweb.spinning.util.Constant;
import cn.bocweb.spinning.util.DeviceUtil;

public class IntegralExplainActivity extends AppCompatActivity {

    String url;

    @Bind(R.id.toolbar)
    Toolbar toolbar;
    @Bind(R.id.webview_integral_explain)
    WebView webviewIntegralExplain;
    @BindColor(R.color.white)
    int white;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_integral_explain);
        ButterKnife.bind(this);

        initIntent();
        initToolbar();
        initIntegralExplain();
    }

    private void initIntent() {
        url = getIntent().getStringExtra(Constant.TO_INTEGRAL_EXPLAIN_URL);
    }

    private void initIntegralExplain() {
        if (TextUtils.isEmpty(url)) {
            DeviceUtil.MyToast(this, "获取网页错误");
            finish();
        } else {
            webviewIntegralExplain.loadUrl(url);
        }
    }

    private void initToolbar() {
        toolbar.setTitle("积分说明");
        toolbar.setTitleTextColor(white);
        toolbar.setNavigationIcon(R.mipmap.btn_exit);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
